|
Redundant code is a computer programming term for code, which may be source code or compiled code in a computer program, that has any form of redundancy, such as recomputing a value that has previously been calculated[1] and is still available, code that is never executed (often called unreachable code), or code which is executed but has no external effect (e.g., does not change the output produced by a program), usually known as dead code.
A NOP instruction might be considered to be redundant code that has been explicitly inserted to pad out the instruction stream or introduce a time delay. Identifiers that are declared, but never referenced, are usually termed as redundant declarations. However, in some cases, a NOP can be used to create timing loops by "wasting time".
int foo (int iX) { int iY = iX*2; return iX*2; }
The second iX*2 expression is redundant code and can be replaced by a reference to the variable iY. Alternatively, the definition int iY = iX*2 can instead be removed.